from django.contrib import admin

from myapp.models import Author, Book

@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('name', 'birth_date', 'created_at')  # 列表显示字段
    search_fields = ('name',)  # 搜索字段
    list_filter = ('created_at',)  # 过滤器

@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'publish_date')
    search_fields = ('title', 'author__name')
    list_filter = ('publish_date', 'author')